home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 235_01 / ovstr.c < prev   
Text File  |  1987-06-16  |  2KB  |  62 lines

  1. /*  001  14-Feb-87  ovstr.c
  2.  
  3.         Some OV specific string routines.
  4.  
  5.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  6. */
  7.  
  8. #include "ov.h"
  9.  
  10.  
  11. /*****************************************************************************
  12.                              M U S T A L L O C
  13.  *****************************************************************************/
  14.  
  15. char * ALTCALL
  16. mustalloc(len)         /* allocate memory or die */
  17. int len;
  18. {
  19.    char *mp;
  20.  
  21.    if (mp = (char *) malloc(len))      /* try to allocate, return addr if ok */
  22.       return(mp);
  23.  
  24.    /* Can't allocate, time to die! The following routines better not call us! */
  25.  
  26.    reset_tty();
  27.    putstr("\r\nOverView ran out of memory!\r\n");
  28.    exit();
  29. }
  30.  
  31. /*****************************************************************************
  32.                              M U S T D U P
  33.  *****************************************************************************/
  34.  
  35. char * ALTCALL
  36. mustdup(sp)    /* duplicate a string or die */
  37. char *sp;
  38. {
  39.    char *nsp;
  40.  
  41.    nsp = mustalloc(strlen(sp)+1);
  42.    strcpy(nsp,sp);
  43.    return(nsp);
  44. }
  45.  
  46. /*****************************************************************************
  47.                            M U S T N D U P
  48.  *****************************************************************************/
  49.  
  50. char * ALTCALL
  51. mustndup(sp,n)         /* duplicate part of a string or die! */
  52. char *sp;
  53. int n;
  54. {
  55.    char *nsp;
  56.  
  57.    nsp = mustalloc(n+1);
  58.    *nsp = '\0';
  59.    strncat(nsp,sp,n);
  60.    return(nsp);
  61. }
  62.